<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      .fade-enter-active {
        transition: opacity 1s;
      }
      .fade-enter,
      .fade-leave-to {
        transition: opacity 1s;
        opacity: 0;
      }
      .slide-enter {
        transition: all 1s;
        transform: translate(-500px);
      }
      .slide-enter-active {
        transition: all 1s;
        transform: translate(500px);
      }
      .slide-leave-active {
        transition: translate 1s;
        transform: translate(0);
      }
    </style>
  </head>
  <body>
    <!-- 内置组件 -->
    <!-- <slot></slot>
    <component :is="componentId"></component> 
  
  -->
    <div id="app">
      <!-- 过渡动画组件 -->
      <transition name="fade">
        <p v-if="flag" style="background: skyblue;height: 200px;">你好</p>
      </transition>
      <transition name="slide">
        <list-com v-if="myflag"></list-com>
      </transition>
      <!-- transition-group 过渡列表 -->
      <transition-group name="fade" tag="p">
        <span v-for="item in items" v-bind:key="item" class="list-item">
          {{ item }}
        </span>
      </transition-group>
      <button @click="flag=!flag">切换显示隐藏</button>
      <button @click="myflag=!myflag">切换显示隐藏</button>
    </div>
    <template id="list">
      <div>
        <ul style="background: red; width: 400px;">
          <li v-for="n in 20" :key="n">
            第{{n}}个人
          </li>
        </ul>
      </div>
    </template>
    <script src="vue.js"></script>
    <script>
      var vm = new Vue({
        el: '#app',
        data() {
          return {
            flag: true,
            myflag: true,
            items: [1, 2, 3, 4, 5, 6, 7, 8, 9]
          }
        },
        components: {
          listCom: {
            template: '#list',
            data() {
              return {}
            }
          }
        }
      })
    </script>
  </body>
</html>
